package com.ikaros.controller.admin;

import com.ikaros.emnus.SexEnum;
import com.ikaros.model.entity.SysUser;
import com.ikaros.model.query.UserQuery;
import com.ikaros.service.admin.SysUserService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;
import java.util.Map;

/**
 * Created by Ikaros on 2017/9/28.
 */
@RestController
@RequestMapping("admin/user")
public class UserController extends AbstractController{
    @Autowired
    private SysUserService sysUserService;

    @RequiresPermissions("sys:user:list")
    @RequestMapping(value = "list",method = RequestMethod.GET)
    public ModelAndView userList(Map<String,Object> map){
        List<SysUser> userList = sysUserService.queryList(map);
        ModelAndView view=new ModelAndView("admin/userList");
        /*view.addObject("list",userList);*/
        map.put("list",userList);
        return view;
    }

    @RequestMapping(value = "info/{userId}",method = RequestMethod.GET)
    public SysUser info(@PathVariable("userId") Integer userId){
        return sysUserService.getById(userId);
    }

}
